package com.xplay.xpocker.exception;

import com.xplay.xpocker.util.ObjectUtils;

public abstract class ServiceAssertion {

    protected static void throwException(StatusCodeEnum codeEnum, Object... params) {
        throw new ServiceRuntimeException(codeEnum, params);
    }

    public static void isNull(Object object, StatusCodeEnum codeEnum, Object... params) {
        if (!ObjectUtils.notNull(object)) {
            throwException(codeEnum, params);
        }
    }

    public static void isTrue(boolean object, StatusCodeEnum codeEnum, Object... params) {
        if (object) {
            throwException(codeEnum, params);
        }
    }

    public static void isEmpty(Object object, StatusCodeEnum codeEnum, Object... params) {
        if (ObjectUtils.isEmpty(object)) {
            throwException(codeEnum, params);
        }
    }


    public static void notEmpty(Object object, StatusCodeEnum codeEnum, Object... params) {
        if (!ObjectUtils.isEmpty(object)) {
            throwException(codeEnum, params);
        }
    }
}
